package ${package.Command};


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import org.springframework.stereotype.Component;
import com.xiao.hao.constant.NumberConstants;
import com.dianliantech.common.service.SuperCommand;
import ${package.Entity}.${entity};
import ${package.Entitypagereq}.${entity}QueryPageReq;
import ${package.Mapper}.${table.mapperName};




/**
*
*
* @Description ${table.comment!} dom层实现
* @Author ${author}
* @Date ${date}
*/
@Component
@Slf4j
public class ${entity}Command extends SuperCommand<${table.mapperName}, ${entity}> {


        /**
        * 功能描述: 新增
        *
        * @param entity
        * @return java.lang.Object
        * @author ${author}
        * @date ${date}
        */
        public String insert(${entity} entity) {
            return baseMapper.insert(entity) == NumberConstants.INT_ONE ? String.valueOf(entity.getId()) : null;
        }


        /**
        * 功能描述: 编辑
        *
        * @param entity
        * @return java.lang.Object
        * @author ${author}
        * @date ${date}
        */
        public Integer update(${entity} entity) {
            return baseMapper.updateById(entity);
        }

        /**
        * 功能描述: 删除
        *
        * @param id
        * @return java.lang.Object
        * @author ${author}
        * @date ${date}
        */
        public Integer delete(Long id) {
            return baseMapper.deleteById(id);
        }

        /**
        * 功能描述: 分页查询
        *
        * @param req
        * @return java.lang.Object
        * @author ${author}
        * @date ${date}
        */
        public Page<${entity}> queryPage(${entity}QueryPageReq req) {
            return baseMapper.selectPage(new Page(req.getNum(), req.getSize()), new LambdaQueryWrapper<${entity}>().orderByDesc(${entity}::getCreateTime));

        }


        /**
        * 功能描述: 查询全部
        *
        * @return java.util.List<${package.Entity}.${entity}>
        * @author ${author}
        * @date ${date}
        */
        public List<${entity}> queryAll() {
            return baseMapper.selectList(new LambdaQueryWrapper<${entity}>().orderByDesc(${entity}::getCreateTime));
        }



}



<#--/**-->
<#-- * <p>-->
<#-- * ${table.comment!} 服务实现类-->
<#-- * </p>-->
<#-- *-->
<#-- * @author ${author}-->
<#-- * @since ${date}-->
<#-- */-->
<#--@Service-->
<#--<#if kotlin>-->
<#--open class ${table.serviceImplName} : ${superServiceImplClass}<${table.mapperName}, ${entity}>(), ${table.serviceName} {-->

<#--}-->
<#--<#else>-->
<#--public class ${table.serviceImplName} extends ${superServiceImplClass}<${table.mapperName}, ${entity}> implements ${table.serviceName} {-->

<#--}-->
<#--</#if>-->
